#include "StdAfx.h"
#include "Resource.h"

#include "Instance.h"

using namespace RenderSystem;

Resource::Resource( const String& strId, ResManager& rResMgr )
	:m_strId(strId),m_rResMgr(rResMgr)
{
}


Resource::~Resource(void)
{
}

const String& Resource::GetResourceId( void ) const
{
	return m_strId;
}

Instance* Resource::CreateInstance( const String& strInstanceId )
{
	InstancesIterator itrInstance = m_Instances.begin();
	for( ; itrInstance != m_Instances.end(); ++itrInstance )
	{
		if( (*itrInstance)->GetInstanceId() == strInstanceId )
			return *itrInstance;
	}

	Instance* pNewInstance = this->_CreateInstanceImpl( strInstanceId );
	if( pNewInstance != NULL )
		m_Instances.push_back( pNewInstance );

	return pNewInstance;
}

uint32 Resource::GetInstanceNum( void ) const
{
	return m_Instances.size();
}
